﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MotionControl;
using WHW_NetUtility;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using System.IO;
using HalconDotNet;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using XXTUserUI;

namespace MainFrame
{
    public partial class GlobalMotion
    {
        /// <summary>
        /// 流程-飞达1
        /// </summary>
        public static void Task_FlyLabel1linght()
        {
            try
            {
                Stopwatch sw_Time = new Stopwatch();
                Stopwatch sw_TimeAir = new Stopwatch();
                string str_flow = fly1.ToString();
                int withoutWord = 0;
                while (!GlobalVar.isExit)
                {

                    Thread.Sleep(3);
                    if (!GlobalVar.isEstop)
                    {
                        if (GlobalVar.userConfig.IsAutoFly)
                        {
                            switch (fly1)
                            {
                                case e_Flow_Fly.等待触发飞达:
                                    {
                                        if (GlobalVar.IsflyStart1)
                                        {
                                            GlobalVar.IsflyStart1 = false;
                                            if (GlobalVar.closeSave.curFly1Count >= GlobalVar.motionConfig.fly1_AlarmCount)
                                            {
                                                GlobalVar.isPause = true;
                                                GlobalMotion.TipInfo($"飞达1膜数量已达到报警数量{GlobalVar.motionConfig.fly1_AlarmCount}");
                                            }
                                            else if (GlobalVar.closeSave.curFly1Count >= GlobalVar.motionConfig.fly1_Count)
                                            {
                                                var str = $"飞达1膜数量已达到数量{GlobalVar.motionConfig.fly1_Count}  停机处理";

                                                MachineState(e_MachineStatus.异常急停, str);
                                                continue;
                                            }
                                            GlobalVar.closeSave.curFly1Count++;
                                            var IsWordOk = false;
                                            lock (lockFly)
                                            {
                                                GlobalVar.isFlyingWithoutWord1 = false;
                                                GlobalVar.e_Camera_Word1 = e_Camera_Pos.未拍照;
                                                visionProc.curCameraPlate2 = e_CameraPlate.图案相机平台1;
                                                GlobalVar.cameraList[(int)e_Camera.图案相机].softTrigger();
                                                Stopwatch sw = new Stopwatch();
                                                sw.Restart();
                                                while (!GlobalVar.isExit)
                                                {
                                                    if (sw.ElapsedMilliseconds > 5000 || GlobalVar.isEstop)
                                                    {
                                                        IsWordOk = false;
                                                        break;
                                                    }
                                                    if (GlobalVar.e_Camera_Word1 == e_Camera_Pos.已拍照OK)
                                                    {
                                                        IsWordOk = true;
                                                        break;
                                                    }
                                                    if (GlobalVar.userConfig.IsWordOk)
                                                    {
                                                        IsWordOk = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (!IsWordOk)
                                            {
                                                if (GlobalVar.isEstop)
                                                    continue;
                               
                                                if (1 == GlobalMotion.TipInfo("1号平台文字版识别有问题，是否继续出料？    是则继续出料    否则等待取料"))
                                                {

                                                }
                                                else
                                                {
                                                    //MachineState(e_MachineStatus.异常急停, "平台1文字版识别有问题");
                                                    GlobalVar.isFlying1OK = true;
                                                    continue;
                                                }
                                            }

                                            GlobalVar.isFlying1OK = false;
                                            //if (!Input_CardEx1[(int)e_input_extCard1.飞达1平台有料])
                                            //{
                                            //    GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].JogMove(e_moveDirection.negative);
                                            //}
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].JogMove(e_moveDirection.negative);
                                            sw_TimeAir.Restart();
                                            sw_Time.Restart();
                                            fly1 = e_Flow_Fly.等待标签到位;
                                        }
                                    }
                                    break;
                                case e_Flow_Fly.等待标签到位:
                                    {
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly1TimeOutAlarm)
                                        {
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            if (GlobalVar.isAutoRun)
                                                GlobalMotion.TipInfo("飞达1检测超时 出标失败");
                                            else
                                                displalyInfo.displayErrorMain("飞达1检测超时 出标失败");
                                            fly1 = e_Flow_Fly.等待触发飞达;
                                            break;
                                        }
                                        if (!GlobalMotion.CardExt_2.GetInputIOStatus((int)e_input_extCard2.飞达1测标光纤1))
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop1);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            fly1 = e_Flow_Fly.标签到位;
                                            break;
                                        }
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop1)
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                    }
                                    break;
                                case e_Flow_Fly.标签到位:
                                    {
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop1)
                                        {
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                            if (withoutWord < withoutLimit)
                                            {
                                                var sw_word = new Stopwatch();
                                                sw_word.Restart();
                                                var IsWithout = true;
                                                int t = 0;
                                                while (true)
                                                {
                                                    if (sw_word.ElapsedMilliseconds > 300)
                                                    {
                                                        if (t < 3 && !IsWithout)
                                                        {
                                                            t++;
                                                            sw_word.Restart();
                                                            IsWithout = true;
                                                        }
                                                        else
                                                            break;
                                                    }
                                                    Thread.Sleep(3);
                                                    IsWithout = IsWithout && Input_CardEx1[(int)e_input_extCard1.飞达1平台有料];
                                                }
                                                if (IsWithout)
                                                {
                                                    withoutWord = 0;
                                                    GlobalVar.isFlying1OK = true;
                                                    displalyInfo.displayInfoMain("飞达1出标OK");
                                                }
                                                else
                                                {
                                                    if (GlobalMotion.TipInfo("飞达1无膜出标   是否再触发一次   是:再出标一张  否:视为出标OK") == 1)
                                                    {
                                                        withoutWord++;
                                                        GlobalVar.IsflyStart1 = true;
                                                    }
                                                    else
                                                        GlobalVar.isFlying1OK = true; ;
                                                }
                                            }
                                            else
                                            {
                                                withoutWord = 0;
                                                GlobalVar.isFlying1OK = true;
                                                displalyInfo.displayInfoMain("飞达1出标OK");
                                            }

                                            fly1 = e_Flow_Fly.等待触发飞达;
                                            sw_Time.Stop();
                                            sw_TimeAir.Stop();
                                        }
                                    }
                                    break;
                            }
                            if (GlobalMotion.Input_CardEx2[(int)e_input_extCard2.限位接近开关1] && !GlobalVar.isPause && GlobalVar.isAutoRun)
                            {
                                GlobalVar.isPause = true;
                                GlobalMotion.TipInfo($"飞达1限位接近开关异常");
                            }
                            if (str_flow != fly1.ToString())
                            {
                                str_flow = fly1.ToString();
                                displalyInfo.displayInfoMain("流程飞达1:" + str_flow);
                            }
                        }
                        else
                        {
                            fly1 = e_Flow_Fly.等待触发飞达;
                            GlobalVar.IsflyStart1 = false;
                            GlobalVar.isFlying1OK = false;
                            if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].m_AxisSts.Motion)
                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                        }
                    }
                    else
                    {
                        fly1 = e_Flow_Fly.等待触发飞达;
                        GlobalVar.IsflyStart1 = false;
                        if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].m_AxisSts.Motion)
                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                        GlobalMotion.CardExt_2.setOut((ushort)e_output_extCard2.飞达吹气1, e_out_OnOff.on);

                    }
                }
            }
            catch (Exception ex)
            {
                displalyInfo.displayInfoMain("Task_FlyLabel1" + ex.Message);
            }
        }
        /// <summary>
        /// 飞达1
        /// </summary>
        public static void Task_FlyLabel1()
        {
            try
            {
                Stopwatch sw_Time = new Stopwatch();
                Stopwatch sw_TimeAir = new Stopwatch();
                string str_flow = fly1.ToString();
                //int withoutWord = 0;
                var flyTime1 = DateTime.Now;
                var flyTime2 = DateTime.Now;
                var IsflyLight1 = false;
                var IsflyLight2 = false;
                int nNGtime = 0;
                int WorkAlarm = 0;
                int NoLabel = 1;
                while (!GlobalVar.isExit)
                {

                    Thread.Sleep(3);

                    if (!GlobalVar.isEstop)
                    {
                        if (GlobalVar.userConfig.IsAutoFly)
                        {
                            switch (fly1)
                            {
                                case e_Flow_Fly.等待触发飞达:
                                    {
                                        if (GlobalVar.IsflyStart1)
                                        {
                                            GlobalVar.IsflyStart1 = false;
                                            if (GlobalVar.isAutoRun && !GlobalVar.isPause && GlobalVar.IsEndWork && e_LabelingFlow != e_Flow_Labeling.取标签)
                                            {
                                                displalyInfo.displayInfoMain("结束作业中   不进行出标");
                                                continue;
                                            }
                                            
                                            if (GlobalVar.closeSave.curFly1Count >= GlobalVar.motionConfig.fly1_AlarmCount)
                                            {
                                                GlobalVar.isPause = true;
                                                GlobalMotion.TipInfo($"飞达1膜数量已达到报警数量{GlobalVar.motionConfig.fly1_AlarmCount}");
                                            }
                                            else if (GlobalVar.closeSave.curFly1Count >= GlobalVar.motionConfig.fly1_Count)
                                            {
                                                var str = $"飞达1膜数量已达到数量{GlobalVar.motionConfig.fly1_Count}  停机处理";

                                                MachineState(e_MachineStatus.异常急停, str);
                                                continue;
                                            }
                                            GlobalVar.closeSave.curFly1Count++;

                                            var IsWordOk = false;
                                            GlobalVar.isFlyingWithoutWord1 = false;
                                            GlobalVar.e_Camera_Word1 = e_Camera_Pos.未拍照;

                                            if (GlobalVar.userConfig.IsWordOk)
                                            {
                                                IsWordOk = true;
                                            }
                                            else
                                            {
                                                if (Camera_OCR(e_platePro.平台1, out string Result, out string meg) == 1)
                                                {
                                                    if (Result.Contains("C0"))
                                                    {
                                                        IsWordOk = true;
                                                        GlobalVar.e_Camera_Word1 = e_Camera_Pos.已拍照OK;
                                                    }
                                                    else
                                                    {
                                                        IsWordOk = false;
                                                        GlobalVar.e_Camera_Word1 = e_Camera_Pos.已拍照NG;
                                                    }
                                                }
                                                else
                                                {
                                                    IsWordOk = false;
                                                    GlobalVar.e_Camera_Word1 = e_Camera_Pos.已拍照NG;
                                                }
                                            }
                                            


                                            //lock (lockFly)
                                            //{
                                            //    GlobalVar.isFlyingWithoutWord1 = false;
                                            //    GlobalVar.e_Camera_Word1 = e_Camera_Pos.未拍照;
                                            //    visionProc.curCameraPlate2 = e_CameraPlate.图案相机平台1;
                                            //    GlobalVar.cameraList[(int)e_Camera.图案相机].softTrigger();
                                            //    Stopwatch sw = new Stopwatch();
                                            //    sw.Restart();
                                            //    while (!GlobalVar.isExit)
                                            //    {
                                            //        if (sw.ElapsedMilliseconds > 5000 || GlobalVar.isEstop)
                                            //        {
                                            //            IsWordOk = false;
                                            //            break;
                                            //        }
                                            //        if (GlobalVar.e_Camera_Word1 == e_Camera_Pos.已拍照NG)
                                            //        {
                                            //            IsWordOk = false;
                                            //            break;
                                            //        }
                                            //        if (GlobalVar.userConfig.IsWordOk)
                                            //        {
                                            //            IsWordOk = true;
                                            //            break;
                                            //        }
                                            //    }
                                            //}

                                            if (!IsWordOk)
                                            {
                                                if (GlobalVar.isEstop)
                                                    continue;
                                                WorkAlarm++;
                                                if (WorkAlarm>=GlobalVar.userConfig.WrodAlarm)
                                                {
                                                    WorkAlarm = 0;
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("1号平台文字版识别有问题，是否继续生产    是则继续生产    否则继续取料") != 1)
                                                    {
                                                        //MachineState(e_MachineStatus.异常急停, "平台1文字版识别有问题");
                                                        GlobalVar.isFlying1OK = true;
                                                        GlobalVar.isPause = false;
                                                        continue;
                                                    }
                                                    else
                                                    {
                                                        fly1 = e_Flow_Fly.等待触发飞达;
                                                        GlobalVar.IsflyStart1 = true;
                                                        GlobalVar.isFlying1OK = false;
                                                        GlobalVar.isPause = false;
                                                        //break;
                                                    }
                                                }
                                            }
                                            GlobalVar.isFlying1OK = false;
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].ClearPos();
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].JogMove(e_moveDirection.negative);
                                            sw_TimeAir.Restart();
                                            sw_Time.Restart();
                                            fly1 = e_Flow_Fly.等待标签到位;
                                            //nNGtime = 0;
                                            //WorkAlarm = 0;
                                        }
                                    }
                                    break;
                                case e_Flow_Fly.等待标签到位:
                                    {
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly1TimeOutAlarm)
                                        {
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            if (GlobalVar.userConfig.getFlyNGTimes > nNGtime)
                                            {
                                                //displalyInfo.displayErrorMain("飞达1出标上升沿检测超时 视为缺膜 自动再补一张");
                                                nNGtime++;
                                                //GlobalVar.IsflyStart1 = true;//不自动触发
                                                fly1 = e_Flow_Fly.标签到位;
                                            }
                                            else
                                            {
                                                if (nNGtime >= GlobalVar.userConfig.WrodAlarm)
                                                {
                                                    nNGtime = 0;
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalVar.isAutoRun)
                                                    {
                                                        //GlobalMotion.TipInfo("飞达1出标上升沿检测超时 出标失败");
                                                        if (GlobalMotion.TipInfo("飞达1 等待标签到位超时，是否继续出一张    是则继续生产    否则等待抛料") == 1)
                                                        {
                                                            fly1 = e_Flow_Fly.等待触发飞达;
                                                            GlobalVar.IsflyStart1 = true;
                                                            GlobalVar.isFlying1OK = false;
                                                            
                                                        }
                                                        else
                                                        {
                                                            //MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                            GlobalVar.isFlying1OK = true;
                                                            fly1 = e_Flow_Fly.等待触发飞达;
                                                        }
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        displalyInfo.displayErrorMain("飞达1出标上升沿检测超时 出标失败");
                                                    }
                                                    GlobalVar.isPause = false;
                                                    fly1 = e_Flow_Fly.等待标签下降沿;
                                                }

                                            }
                                            sw_Time.Restart();
                                            break;
                                        }

                                        if (Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤1] && Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤2])
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.fly1Updeley);
                                            if (Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤1] && Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤2])
                                            {
                                                IsflyLight1 = false;
                                                IsflyLight2 = false;
                                                fly1 = e_Flow_Fly.等待标签下降沿;
                                                break;
                                            }
                                        }

                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop1)
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                    }
                                    break;
                                case e_Flow_Fly.等待标签下降沿:
                                    {
                                        nNGtime = 0;
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly1TimeOutAlarm)
                                        {
                                            if (NoLabel> GlobalVar.userConfig.NoLabel)
                                            {
                                                NoLabel = 0;
                                                GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                                if (GlobalVar.isAutoRun)
                                                {
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("飞达1 飞达1检测超时,出标失败，是否继续出一张    是则继续生产    否则抛料") == 1)
                                                    {
                                                        fly1 = e_Flow_Fly.等待触发飞达;
                                                        GlobalVar.IsflyStart1 = true;
                                                        GlobalVar.isFlying1OK = false;
                                                        //break;
                                                    }
                                                    else
                                                    {
                                                        //MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                        GlobalVar.isFlying1OK = true;
                                                    }
                                                }
                                                    //GlobalMotion.TipInfo("飞达1检测超时 出标失败");
                                                else
                                                    displalyInfo.displayErrorMain("飞达1检测超时 出标失败");
                                                fly1 = e_Flow_Fly.等待触发飞达;
                                                GlobalVar.isPause = false;
                                                break;
                                            }
                                            else
                                            {
                                                Thread.Sleep(GlobalVar.motionConfig.FlyStop1);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                                fly1 = e_Flow_Fly.标签到位;
                                            }
                                            NoLabel++;
                                            break;
                                        }

                                        if (!Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤1] && !IsflyLight1)
                                        {
                                            displalyInfo.displayInfoMain("飞达1测标光纤1下降沿");
                                            flyTime1 = DateTime.Now;
                                            IsflyLight1 = true;
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop1);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            fly1 = e_Flow_Fly.标签到位;
                                            break;
                                        }

                                        if (!Input_CardEx2[(int)e_input_extCard2.飞达1测标光纤2] && !IsflyLight2)
                                        {
                                            displalyInfo.displayInfoMain("飞达1测标光纤2下降沿");
                                            flyTime2 = DateTime.Now;
                                            IsflyLight2 = true;
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop1);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            fly1 = e_Flow_Fly.标签到位;
                                            break;
                                        }

                                        if (IsflyLight1 && IsflyLight2)
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop1);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                                            fly1 = e_Flow_Fly.标签到位;
                                            break;
                                        }
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop1)
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);
                                    }
                                    break;
                                case e_Flow_Fly.标签到位:
                                    {
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop1)
                                        {
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气1, e_out_OnOff.on);

                                            var sw_word = new Stopwatch();
                                            sw_word.Restart();
                                            var IsWithout = true;
                                            var nMs = (flyTime1 - flyTime2).TotalMilliseconds;
                                            var angel = nMs * GlobalVar.motionConfig.fly1AngelUnit;
                                            if (angel >= GlobalVar.motionConfig.fly1AngelStart && angel <= GlobalVar.motionConfig.fly1AngelEnd)
                                            {
                                                GlobalVar.isFlying1OK = true;
                                                displalyInfo.displayInfoMain("飞达1出标OK");
                                            }
                                            else
                                            {
                                                //GlobalVar.isPause = true;
                                                if (GlobalMotion.TipInfo("飞达1出标角度过大   是否视为OK   是:视为出标OK  否:视为出标NG") == 1)
                                                {
                                                    //withoutWord = 0;
                                                    GlobalVar.isFlying1OK = true;
                                                    displalyInfo.displayInfoMain("飞达1出标OK");
                                                }
                                                else
                                                {
                                                    if (GlobalVar.isAutoRun)
                                                    {
                                                       
                                                        if (GlobalMotion.TipInfo("飞达1 检测超时,出标失败，是否继续出一张    是则继续生产    否则抛料") == 1)
                                                        {
                                                            fly1 = e_Flow_Fly.等待触发飞达;
                                                            GlobalVar.IsflyStart1 = true;
                                                            GlobalVar.isFlying1OK = false;
                                                            //break;
                                                        }
                                                        else
                                                        {
                                                            //MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                            GlobalVar.isFlying1OK = true;
                                                            fly1 = e_Flow_Fly.等待触发飞达;
                                                        }
                                                        GlobalVar.isPause = false;
                                                    }
                                                        //GlobalMotion.TipInfo("飞达1检测超时 出标失败");
                                                    else
                                                        displalyInfo.displayErrorMain("飞达1检测超时 出标失败");
                                                }
                                                
                                            }
                                            fly1 = e_Flow_Fly.等待触发飞达;
                                            sw_Time.Stop();
                                            sw_TimeAir.Stop();
                                        }
                                    }
                                    break;
                            }

                            if (GlobalMotion.Input_CardEx2[(int)e_input_extCard2.限位接近开关1] && !GlobalVar.isPause && GlobalVar.isAutoRun)
                            {
                                //GlobalVar.isPause = true;
                                GlobalVar.isPause = true;
                                GlobalMotion.TipInfo($"飞达1限位接近开关异常");
                                GlobalVar.isPause = false;
                            }

                            if (str_flow != fly1.ToString())
                            {
                                str_flow = fly1.ToString();
                                displalyInfo.displayInfoMain("流程飞达1:" + str_flow);
                            }
                        }
                        else
                        {
                            fly1 = e_Flow_Fly.等待触发飞达;
                            GlobalVar.IsflyStart1 = false;
                            GlobalVar.isFlying1OK = false;
                            if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].m_AxisSts.Motion)
                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                        }
                    }
                    else
                    {
                        fly1 = e_Flow_Fly.等待触发飞达;
                        GlobalVar.IsflyStart1 = false;
                        if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].m_AxisSts.Motion)
                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引1].AxisStop();
                        GlobalMotion.CardExt_2.setOut((ushort)e_output_extCard2.飞达吹气1, e_out_OnOff.on);

                    }
                }
            }
            catch (Exception ex)
            {
                displalyInfo.displayInfoMain("Task_FlyLabel1" + ex.Message);
            }
        }
        /// <summary>
        /// 上限3次
        /// </summary>
        private static int withoutLimit = 3;
        /// <summary>
        /// 流程-飞达2
        /// </summary>
        public static void Task_FlyLabel2light()
        {
            try
            {

                Stopwatch sw_TimeAir = new Stopwatch();
                Stopwatch sw_Time = new Stopwatch();
                string str_flow = fly2.ToString();
                int withoutWord = 0;
                while (!GlobalVar.isExit)
                {

                    Thread.Sleep(3);
                    if (!GlobalVar.isEstop)
                    {
                        if (GlobalVar.userConfig.IsAutoFly)
                        {
                            switch (fly2)
                            {
                                case e_Flow_Fly.等待触发飞达:
                                    {
                                        if (GlobalVar.IsflyStart2)
                                        {
                                            GlobalVar.IsflyStart2 = false;
                                            if (GlobalVar.closeSave.curFly2Count >= GlobalVar.motionConfig.fly2_AlarmCount)
                                            {
                                                GlobalVar.isPause = true;
                                                GlobalMotion.TipInfo($"飞达2膜数量已达到报警数量{GlobalVar.motionConfig.fly2_AlarmCount}");
                                            }
                                            if (GlobalVar.closeSave.curFly2Count >= GlobalVar.motionConfig.fly2_Count)
                                            {
                                                var str = $"飞达2膜数量已达到数量{GlobalVar.motionConfig.fly2_Count}  停机处理";
                                                MachineState(e_MachineStatus.异常急停, str);
                                                continue;
                                            }
                                            GlobalVar.closeSave.curFly2Count++;
                                            var IsWordOk = false;
                                            lock (lockFly)
                                            {
                                                GlobalVar.isFlyingWithoutWord2 = false;
                                                GlobalVar.e_Camera_Word2 = e_Camera_Pos.未拍照;
                                                visionProc.curCameraPlate2 = e_CameraPlate.图案相机平台2;
                                                GlobalVar.cameraList[(int)e_Camera.图案相机].softTrigger();
                                                Stopwatch sw = new Stopwatch();
                                                sw.Restart();
                                                while (!GlobalVar.isExit)
                                                {
                                                    if (sw.ElapsedMilliseconds > 10000 || GlobalVar.isEstop)
                                                    {
                                                        IsWordOk = false;
                                                        break;
                                                    }
                                                    if (GlobalVar.e_Camera_Word2 == e_Camera_Pos.已拍照OK)
                                                    {
                                                        IsWordOk = true;
                                                        break;
                                                    }
                                                    if (GlobalVar.userConfig.IsWordOk)
                                                    {
                                                        IsWordOk = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (!IsWordOk)
                                            {
                                                if (GlobalVar.isEstop)
                                                    continue;

                                                if (GlobalMotion.TipInfo("飞达2 平台文字版识别有问题,出标失败，是否继续出一张    是则继续生产    否则急停") == 1)
                                                {
                                                    fly1 = e_Flow_Fly.等待触发飞达;
                                                    GlobalVar.IsflyStart1 = true;
                                                    GlobalVar.isFlying1OK = false;
                                                    break;
                                                }
                                                else
                                                {
                                                    MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                }

                                                //if (1 == GlobalMotion.TipInfo("2号平台文字版识别有问题，是否继续生产    是则继续生产    否则急停"))
                                                //{

                                                //}
                                                //else
                                                //{
                                                //    MachineState(e_MachineStatus.异常急停, "平台2文字版识别有问题");
                                                //    continue;
                                                //}
                                            }
                                            GlobalVar.isFlying2OK = false;
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].JogMove(e_moveDirection.positive);
                                            sw_Time.Restart();
                                            sw_TimeAir.Restart();
                                            fly2 = e_Flow_Fly.等待标签到位;
                                        }
                                    }
                                    break;
                                case e_Flow_Fly.等待标签到位:
                                    {
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly2TimeOutAlarm)
                                        {
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            if (GlobalVar.isAutoRun)
                                            {
                                                if (GlobalMotion.TipInfo("飞达2 等待标签到位超时,出标失败，是否继续出一张    是则继续生产    否则急停") == 1)
                                                {
                                                    fly1 = e_Flow_Fly.等待触发飞达;
                                                    GlobalVar.IsflyStart1 = true;
                                                    GlobalVar.isFlying1OK = false;
                                                    //break;
                                                }
                                                else
                                                {
                                                    MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                }
                                            }
                                                //GlobalMotion.TipInfo("飞达2检测超时  出标失败");
                                            else
                                                displalyInfo.displayErrorMain("飞达2检测超时  出标失败");

                                            fly2 = e_Flow_Fly.等待触发飞达;
                                            break;
                                        }
                                        if (!GlobalMotion.CardExt_2.GetInputIOStatus((int)e_input_extCard2.飞达1测标光纤2))
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            fly2 = e_Flow_Fly.标签到位;
                                            break;
                                        }
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop2)
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                    }
                                    break;
                                case e_Flow_Fly.标签到位:
                                    {
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop2)
                                        {

                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                            if (withoutWord < withoutLimit)
                                            //         if (!GlobalVar.userConfig.IsWordOk && GlobalVar.isFlyingWithoutWord2 && withoutWord < 1)
                                            {
                                                var sw_word = new Stopwatch();
                                                sw_word.Restart();
                                                var IsWithout = true;
                                                int t = 0;
                                                while (true)
                                                {
                                                    if (sw_word.ElapsedMilliseconds > 300)
                                                    {
                                                        if (t < 3 && !IsWithout)
                                                        {
                                                            t++;
                                                            sw_word.Restart();
                                                            IsWithout = true;
                                                        }
                                                        else
                                                            break;
                                                    }
                                                    Thread.Sleep(3);
                                                    IsWithout = IsWithout && Input_CardEx1[(int)e_input_extCard1.飞达2平台有料];
                                                }
                                                if (IsWithout)
                                                {
                                                    withoutWord = 0;
                                                    GlobalVar.isFlying2OK = true;
                                                    displalyInfo.displayInfoMain("飞达2出标OK");
                                                }
                                                else
                                                {
                                                    if (GlobalMotion.TipInfo("飞达2缺膜出标   是否再触发一次   是:再出标一张  否:视为出标OK") == 1)
                                                    {
                                                        withoutWord++;
                                                        GlobalVar.IsflyStart2 = true;
                                                    }
                                                    else
                                                        GlobalVar.isFlying2OK = true; ;
                                                }
                                            }
                                            else
                                            {
                                                withoutWord = 0;
                                                GlobalVar.isFlying2OK = true;
                                                displalyInfo.displayInfoMain("飞达2出标OK");
                                            }
                                            sw_Time.Stop();
                                            sw_TimeAir.Stop();
                                            fly2 = e_Flow_Fly.等待触发飞达;
                                        }
                                    }
                                    break;
                            }
                            if (GlobalMotion.Input_CardEx2[(int)e_input_extCard2.限位接近开关2] && !GlobalVar.isPause && GlobalVar.isAutoRun)
                            {
                                GlobalVar.isPause = true;
                                GlobalMotion.TipInfo($"飞达2限位接近开关异常");
                            }
                            if (str_flow != fly2.ToString())
                            {
                                str_flow = fly2.ToString();
                                displalyInfo.displayInfoMain("流程飞达2:" + str_flow);
                            }
                        }
                        else
                        {
                            GlobalVar.isFlying2OK = true;
                            GlobalVar.IsflyStart2 = false;
                            if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].m_AxisSts.Motion)
                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                            fly2 = e_Flow_Fly.等待触发飞达;
                        }
                    }
                    else
                    {
                        GlobalVar.IsflyStart2 = false;
                        if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].m_AxisSts.Motion)
                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                        GlobalMotion.CardExt_2.setOut((ushort)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                        fly2 = e_Flow_Fly.等待触发飞达;
                    }
                }
            }
            catch (Exception ex)
            {
                displalyInfo.displayInfoMain("Task_FlyLabel2" + ex.Message);
            }
        }
        /// <summary>
        /// 飞达2
        /// </summary>
        public static void Task_FlyLabel2()
        {
            try
            {

                Stopwatch sw_TimeAir = new Stopwatch();
                Stopwatch sw_Time = new Stopwatch();
                string str_flow = fly2.ToString();
                int withoutWord = 0;
                var flyTime1 = DateTime.Now;
                var flyTime2 = DateTime.Now;
                var IsflyLight1 = false;
                var IsflyLight2 = false;
                var nNGtime = 0;
                int WorkAlarm = 0;
                int NoLabel = 1;
                while (!GlobalVar.isExit)
                {

                    Thread.Sleep(3);

                    if (!GlobalVar.isEstop)
                    {
                        if (GlobalVar.userConfig.IsAutoFly)
                        {
                            switch (fly2)
                            {
                                case e_Flow_Fly.等待触发飞达:
                                    {
                                        if (GlobalVar.IsflyStart2)
                                        {
                                            GlobalVar.IsflyStart2 = false;
                                            if (GlobalVar.isAutoRun && !GlobalVar.isPause && GlobalVar.IsEndWork && e_LabelingFlow != e_Flow_Labeling.取标签)
                                            {
                                                displalyInfo.displayInfoMain("结束作业中   不进行出标");
                                                continue;
                                            }
                                            if (GlobalVar.closeSave.curFly2Count >= GlobalVar.motionConfig.fly2_AlarmCount)
                                            {
                                                GlobalVar.isPause = true;
                                                GlobalMotion.TipInfo($"飞达2膜数量已累计达到报警数量{GlobalVar.motionConfig.fly2_AlarmCount}");
                                            }
                                            if (GlobalVar.closeSave.curFly2Count >= GlobalVar.motionConfig.fly2_Count)
                                            {
                                                var str = $"飞达2膜数量已达到数量{GlobalVar.motionConfig.fly2_Count}  停机处理";
                                                MachineState(e_MachineStatus.异常急停, str);
                                                continue;
                                            }
                                            GlobalVar.closeSave.curFly2Count++;
                                            var IsWordOk = false;
                                            GlobalVar.isFlyingWithoutWord2 = false;
                                            GlobalVar.e_Camera_Word2 = e_Camera_Pos.未拍照;

                                            if (GlobalVar.userConfig.IsWordOk)
                                            {
                                                IsWordOk = true;
                                            }
                                            else
                                            {
                                                if (Camera_OCR(e_platePro.平台2, out string Result, out string meg) == 1)
                                                {
                                                    if (Result.Contains("C0"))
                                                    {
                                                        IsWordOk = true;
                                                        GlobalVar.e_Camera_Word2 = e_Camera_Pos.已拍照OK;
                                                    }
                                                    else
                                                    {
                                                        IsWordOk = false;
                                                        GlobalVar.e_Camera_Word2 = e_Camera_Pos.已拍照NG;
                                                    }
                                                }
                                                else
                                                {
                                                    IsWordOk = false;
                                                    GlobalVar.e_Camera_Word2 = e_Camera_Pos.已拍照NG;
                                                }
                                            }

                                            


                                            //lock (lockFly)
                                            //{
                                            //    GlobalVar.isFlyingWithoutWord2 = false;
                                            //    GlobalVar.e_Camera_Word2 = e_Camera_Pos.未拍照;
                                            //    visionProc.curCameraPlate2 = e_CameraPlate.图案相机平台2;
                                            //    GlobalVar.cameraList[(int)e_Camera.图案相机].softTrigger();
                                            //    Stopwatch sw = new Stopwatch();
                                            //    sw.Restart();
                                            //    while (!GlobalVar.isExit)
                                            //    {
                                            //        if (sw.ElapsedMilliseconds > 10000 || GlobalVar.isEstop)
                                            //        {
                                            //            IsWordOk = false;
                                            //            break;
                                            //        }
                                            //        if (GlobalVar.e_Camera_Word2 == e_Camera_Pos.已拍照NG)
                                            //        {
                                            //            IsWordOk = false;
                                            //            break;
                                            //        }
                                            //        if (GlobalVar.userConfig.IsWordOk)
                                            //        {
                                            //            IsWordOk = true;
                                            //            break;
                                            //        }
                                            //    }
                                            //}

                                            if (!IsWordOk)
                                            {
                                                if (GlobalVar.isEstop)
                                                    continue;
                                                WorkAlarm++;
                                                if (WorkAlarm >= GlobalVar.userConfig.WrodAlarm)
                                                {
                                                    WorkAlarm = 0;
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("2号平台文字版识别有问题，是否继续出料    是则继续生产    否则继续取料") != 1)
                                                    {
                                                        //MachineState(e_MachineStatus.异常急停, "平台2文字版识别有问题");
                                                        GlobalVar.isFlying1OK = true;
                                                        GlobalVar.isPause = false;
                                                        continue;
                                                    }
                                                    GlobalVar.isPause = false;
                                                }
                                            }

                                            GlobalVar.isFlying2OK = false;
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].ClearPos();

                                            if (!Input_CardEx1[(int)e_input_extCard1.飞达2平台有料])
                                            {
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].JogMove(e_moveDirection.positive);
                                            }
                                            //出料
                                           
                                            sw_Time.Restart();
                                            sw_TimeAir.Restart();
                                            fly2 = e_Flow_Fly.等待标签到位;
                                        }
                                    }
                                    break;
                                case e_Flow_Fly.等待标签到位:
                                    {
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly2TimeOutAlarm)
                                        {
                                            //GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            //GlobalMotion.CardExt_2.setOut((ushort)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                            //if (GlobalVar.userConfig.getFlyNGTimes > nNGtime)
                                            //{
                                            //    //displalyInfo.displayErrorMain("飞达2出标上升沿检测超时 视为缺膜 自动再补一张");
                                            //    nNGtime++;
                                            //    GlobalVar.IsflyStart2 = true;
                                            //    fly2 = e_Flow_Fly.等待触发飞达;
                                            //}
                                            //else
                                            //{
                                            //    if (GlobalVar.isAutoRun)
                                            //        GlobalMotion.TipInfo("飞达2出标上升沿检测超时 出标失败");
                                            //    else
                                            //        displalyInfo.displayErrorMain("飞达2出标上升沿检测超时 出标失败");
                                            //    fly2 = e_Flow_Fly.等待触发飞达;
                                            //    nNGtime = 0;
                                            //}
                                            //break;
                                            if (NoLabel > GlobalVar.userConfig.NoLabel)
                                            {
                                                NoLabel = 0;
                                                GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                                if (GlobalVar.isAutoRun)
                                                {
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("飞达2 飞达1检测超时,出标失败，是否继续出一张    是则继续生产    否则抛料") == 1)
                                                    {
                                                        fly2 = e_Flow_Fly.等待触发飞达;
                                                        GlobalVar.IsflyStart2 = true;
                                                        GlobalVar.isFlying2OK = false;
                                                        //break;
                                                    }
                                                    else
                                                    {
                                                        GlobalVar.isFlying2OK = true;
                                                    }
                                                }
                              
                                                else
                                                    displalyInfo.displayErrorMain("飞达2检测超时 出标失败");
                                                fly2 = e_Flow_Fly.等待触发飞达;
                                                GlobalVar.isPause = false;
                                                break;
                                            }
                                            else
                                            {
                                                Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                                fly2 = e_Flow_Fly.标签到位;
                                            }
                                            NoLabel++;
                                            break;
                                        }

                                        if (Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤1] && Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤2])
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.fly2Updeley);
                                            if (Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤1] && Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤2])
                                            {
                                                IsflyLight1 = false;
                                                IsflyLight2 = false;
                                                fly2 = e_Flow_Fly.等待标签下降沿;
                                                break;
                                            }
                                        }

                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop2)
                                        {
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                        }

                                    }
                                    break;
                                case e_Flow_Fly.等待标签下降沿:
                                    {
                                        nNGtime = 0;
                                        if (sw_Time.ElapsedMilliseconds > GlobalVar.motionConfig.Fly2TimeOutAlarm)
                                        {

                                            //GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                            //GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();

                                            //if (NoLabel >= GlobalVar.userConfig.NoLabel)
                                            //{
                                            //    if (GlobalVar.isAutoRun)
                                            //        GlobalMotion.TipInfo("飞达2检测超时 出标失败");
                                            //    else
                                            //        displalyInfo.displayErrorMain("飞达2检测超时 出标失败");
                                            //    fly1 = e_Flow_Fly.等待触发飞达;
                                            //    NoLabel = 0;
                                            //    break;
                                            //}
                                            //else
                                            //{
                                            //    fly2 = e_Flow_Fly.标签到位;
                                            //    NoLabel++;
                                            //}

                                            //break;
                                            if (NoLabel > GlobalVar.userConfig.NoLabel)
                                            {
                                                NoLabel = 0;
                                                GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                                if (GlobalVar.isAutoRun)
                                                {
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("飞达2 飞达1检测超时,出标失败，是否继续出一张    是则继续生产    否则抛料") == 1)
                                                    {
                                                        fly2 = e_Flow_Fly.等待触发飞达;
                                                        GlobalVar.IsflyStart2 = true;
                                                        GlobalVar.isFlying2OK = false;
                                                        //break;
                                                    }
                                                    else
                                                    {
                                                        //MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                        GlobalVar.isFlying2OK = true;
                                                    }
                                                }
                                                //GlobalMotion.TipInfo("飞达1检测超时 出标失败");
                                                else
                                                    displalyInfo.displayErrorMain("飞达2检测超时 出标失败");
                                                fly2 = e_Flow_Fly.等待触发飞达;
                                                GlobalVar.isPause = false;
                                                break;
                                            }
                                            else
                                            {
                                                Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                                fly2 = e_Flow_Fly.标签到位;
                                            }
                                            NoLabel++;

                                            break;
                                        }

                                        if (!Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤1] && !IsflyLight1)
                                        {
                                            displalyInfo.displayInfoMain("飞达2测标光纤1下降沿");
                                            flyTime1 = DateTime.Now;
                                            IsflyLight1 = true;
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            fly2 = e_Flow_Fly.标签到位;
                                            break;
                                        }

                                        if (!Input_CardEx2[(int)e_input_extCard2.飞达2测标光纤2] && !IsflyLight2)
                                        {
                                            displalyInfo.displayInfoMain("飞达2测标光纤2下降沿");
                                            flyTime2 = DateTime.Now;
                                            IsflyLight2 = true;
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            fly2 = e_Flow_Fly.标签到位;
                                            break;
                                        }
                                        if (IsflyLight1 && IsflyLight2)
                                        {
                                            Thread.Sleep(GlobalVar.motionConfig.FlyStop2);
                                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                                            fly2 = e_Flow_Fly.标签到位;
                                            break;
                                        }
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop2)
                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                    }
                                    break;
                                case e_Flow_Fly.标签到位:
                                    {
                                        if (sw_TimeAir.ElapsedMilliseconds > GlobalVar.motionConfig.delayFlyStop2)
                                        {

                                            GlobalMotion.CardExt_2.setOut((int)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                                            var sw_word = new Stopwatch();
                                            sw_word.Restart();
                                            var IsWithout = true;
                                            var nMs = (flyTime1 - flyTime2).TotalMilliseconds;
                                            var angel = nMs * GlobalVar.motionConfig.fly2AngelUnit;
                                            if (angel >= GlobalVar.motionConfig.fly2AngelStart && angel <= GlobalVar.motionConfig.fly2AngelEnd)
                                            {
                                                int t = 0;
                                                {
                                                    GlobalVar.isFlying2OK = true;
                                                    displalyInfo.displayInfoMain("飞达2出标OK");
                                                }
                                            }
                                            else
                                            {
                                                if (GlobalMotion.TipInfo("飞达2出标角度过大   是否视为OK   是:视为出标OK  否:视为出标NG") == 1)
                                                {
                                                    withoutWord = 0;
                                                    GlobalVar.isFlying2OK = true;
                                                    displalyInfo.displayInfoMain("飞达2出标OK");
                                                }
                                                else
                                                {
                                                    //if (GlobalVar.isAutoRun)
                                                    //    GlobalMotion.TipInfo_fly("飞达2检测超时 出标失败");
                                                    //else
                                                    //    displalyInfo.displayErrorMain("飞达2检测超时 出标失败");
                                                    //GlobalVar.isPause = true;
                                                    if (GlobalMotion.TipInfo("飞达1出标角度过大   是否视为OK   是:视为出标OK  否:视为出标NG") == 1)
                                                    {
                                                        //withoutWord = 0;
                                                        GlobalVar.isFlying2OK = true;
                                                        displalyInfo.displayInfoMain("飞达2出标OK");
                                                    }
                                                    else
                                                    {
                                                        if (GlobalVar.isAutoRun)
                                                        {
                                                            if (GlobalMotion.TipInfo("飞达2 检测超时,出标失败，是否继续出一张    是则继续生产    否则抛料") == 1)
                                                            {
                                                                fly2 = e_Flow_Fly.等待触发飞达;
                                                                GlobalVar.IsflyStart2 = true;
                                                                GlobalVar.isFlying2OK = false;
                                                                //break;
                                                            }
                                                            else
                                                            {
                                                                //MachineState(e_MachineStatus.异常急停, "平台1 等待标签到位超时");
                                                                GlobalVar.isFlying2OK = true;
                                                                fly2 = e_Flow_Fly.等待触发飞达;
                                                            }
                                                            GlobalVar.isPause = false;
                                                        }
                                                        else
                                                            displalyInfo.displayErrorMain("飞达2检测超时 出标失败");
                                                    }

                                                }

                                            }
                                            fly2 = e_Flow_Fly.等待触发飞达;
                                        }
                                    }
                                    break;
                            }

                            if (GlobalMotion.Input_CardEx2[(int)e_input_extCard2.限位接近开关2] && !GlobalVar.isPause && GlobalVar.isAutoRun)
                            {
                                GlobalVar.isPause = true;
                                GlobalMotion.TipInfo($"飞达2限位接近开关异常");
                            }
                            if (str_flow != fly2.ToString())
                            {
                                str_flow = fly2.ToString();
                                displalyInfo.displayInfoMain("流程飞达2:" + str_flow);
                            }
                        }
                        else
                        {
                            GlobalVar.isFlying2OK = true;
                            GlobalVar.IsflyStart2 = false;
                            if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].m_AxisSts.Motion)
                                GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                            fly2 = e_Flow_Fly.等待触发飞达;
                        }
                    }
                    else
                    {
                        GlobalVar.IsflyStart2 = false;
                        if (GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].m_AxisSts.Motion)
                            GlobalMotion.Card_1.AxisList[(int)e_card1_axis.飞达牵引2].AxisStop();
                        GlobalMotion.CardExt_2.setOut((ushort)e_output_extCard2.飞达吹气2, e_out_OnOff.on);
                        fly2 = e_Flow_Fly.等待触发飞达;
                    }
                }
            }
            catch (Exception ex)
            {
                displalyInfo.displayInfoMain("Task_FlyLabel2" + ex.Message);
            }
        }

    }
}
